import Vue from 'vue';
Vue.filter( 'unixToDate', (timestamp, isTime, removeSecond)=>{
    if( !timestamp ) return '';
    let time = new Date( timestamp),
        date = '',
        month = time.getMonth() + 1,
        day = time.getDate();
    if( time == 'Invalid Date') return timestamp;

    date += time.getFullYear() + "-";
    date += (month < 10 ?'0' + month : month) + "-";
    date += (day < 10 ?'0' + day : day) ;
    if(isTime && !removeSecond){
      date +=" "+(time.getHours() < 10 ?'0' + time.getHours() : time.getHours()) + ":";
      date += (time.getUTCMinutes() < 10 ? '0' + time.getUTCMinutes() : time.getUTCMinutes()) + ":";
      date += time.getUTCSeconds() < 10 ? '0' + time.getUTCSeconds() : time.getUTCSeconds();
    }else if ( isTime && removeSecond) {}{
        date +=" "+(time.getHours() < 10 ?'0' + time.getHours() : time.getHours()) + ":";
        date += (time.getUTCMinutes() < 10 ? '0' + time.getUTCMinutes() : time.getUTCMinutes());
    }
    return date;
})